/**
	@file string.h
	String routines. Implementation of standard string.h c library.
	Refer to msdn for documentation.
	@note Copyright (C) 2002 Michael Ringgaard. All rights reserved.
	@par Edited:
		Konstantin Kastanov
*/

//
// string.h
//
// String routines
//
// Copyright (C) 2002 Michael Ringgaard. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 
// 1. Redistributions of source code must retain the above copyright 
//    notice, this list of conditions and the following disclaimer.  
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.  
// 3. Neither the name of the project nor the names of its contributors
//    may be used to endorse or promote products derived from this software
//    without specific prior written permission. 
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
// SUCH DAMAGE.


#ifndef STRING_H
#define STRING_H

#include "dataTypes.h"

#ifdef  __cplusplus
extern "C" {
#endif

char *strncpy(char *dest, const char *source, u32int n);
int strncmp(const char *s1, const char *s2, u32int n);
int stricmp(const char *s1, const char *s2);
int strnicmp(const char *s1, const char *s2, u32int n);
char *strchr(const char *s, int ch);
char *strrchr(const char *s, int ch);
char *strstr(const char *s1, const char *s2);
u32int strspn(const char *string, const char *control);
u32int strcspn(const char *string, const char *control);
char *strpbrk(const char *string, const char *control);

int strcasecmp(const char *s1, const char *s2);
int strncasecmp(const char *s1, const char *s2, u32int n);

int strcoll(const char *s1, const char *s2);


//char *strdup(const char *s);


char *strlwr(char *s);
char *strupr(char *s);

char *strncat(char *s1, const char *s2, u32int n);
char *strnset(char *s, int c, u32int n);
char *strset(char *s, int c);
char *strrev(char *s);
char *strtok(char *string, const char *control);
char *strtok_r(char *string, const char *control, char **lasts);

void *memmove(void *dst, const void *src, u32int n);
void *memchr(const void *buf, int ch, u32int n);

void *memccpy(void *dst, const void *src, int c, u32int n);
int memicmp(const void *buf1, const void *buf2, u32int n);

// Intrinsic functions

void *memcpy(void *, const void *, u32int);
int memcmp(const void *, const void *, u32int);
void *memset(void *, int, u32int);

char *strcpy(char *, const char *);
char *strcat(char *, const char *);
int strcmp(const char *, const char *);
u32int strlen(const char *);

//------------Added functions (not exist in standard string.h)-------//

s8int *strToLower(s8int *str);
s8int *strToUpper(s8int *str);
s8int *strnchr(const char *s, int ch, int n); //n - number o characters
s8int *strnrchr(const char *s, int ch, int n);


#ifdef  __cplusplus
}
#endif

#endif
